package com.siki.vo.position;


import com.siki.pojo.commonEntity.TalentPosition;
import com.siki.pojo.enumeration.common.EducationClaim;
import com.siki.pojo.enumeration.common.PositionCategory;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.springframework.beans.BeanUtils;

import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import java.util.Optional;

/**
 * @Author Siki
 * @Date 2020/6/21
 */
@ApiModel("个人用户查询企业信息VO")
@Getter
@Setter
@NoArgsConstructor
public class TalentPositionUserListVO {
    @ApiModelProperty("岗位所属公司")
    String realName;

    @ApiModelProperty(value = "职位名称")
    private String positionName;

    @ApiModelProperty(value = "职位的类别")
    private String positionCategory;

    @ApiModelProperty(value = "最高工资")
    private String maximumWage;

    @ApiModelProperty(value = "最低工资")
    private String minimumWage;

    @ApiModelProperty(value = "工作地点")
    private String workPlace;

    @ApiModelProperty(value = "学历要求")
    private String educationClaim;

    @ApiModelProperty(value = "职位特点")
    private String positionFeatures;

    @ApiModelProperty(value = "职位描述")
    private String positionDescription;

    public TalentPositionUserListVO(TalentPosition talentPositions){
        Optional.ofNullable(talentPositions).ifPresent(talentPosition -> {
            Optional.ofNullable(talentPosition.getEnterprise()).ifPresent(enterprise ->{
                Optional.of(enterprise.getSysUser()).ifPresent(sysUser -> {
                    this.realName=sysUser.getRealName();
                });
            } );
            //映射
            BeanUtils.copyProperties(talentPosition,this);
            //学历要求
            this.educationClaim = Optional.ofNullable(talentPosition.getEducationClaim()).map(EducationClaim::getName).orElse(null);
            //职位类别
            this.positionCategory= Optional.ofNullable(talentPosition.getPositionCategory()).map(PositionCategory::getName).orElse(null);
        });
    }
}
